package com.example.bilibili_miaosha.config;

import com.example.bilibili_miaosha.entity.User;

/**
 * @ClassName UserContext
 * @Description 这个线程在接口限流拦截器中使用，为这个线程保存User
 * @Author 川
 * @Date 2022/4/9 15:32
 * @Version 1.0
 **/
public class UserContext {
    private static ThreadLocal<User> userHolder = new ThreadLocal<User>();

    public static void setUser(User user) {
        userHolder.set(user);
    }

    public static User getUser() {
        return userHolder.get();
    }
}
